package com.heima.admin.controller.v1;

import com.heima.model.common.dtos.ChannelDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.admin.service.AdChannelService;

import com.heima.model.common.pojos.AdChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")

public class AdChannelController {
    /**
     * 根据名称分页查询频道列表
     * @param dto
     * @return
     */
    @Autowired
    private AdChannelService adChannelService;
    @PostMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDTO dto){
        return adChannelService.findByNameAndPage(dto);
    }

    @PostMapping("/save")
    public ResponseResult add(@RequestBody AdChannel adChannel){
        return adChannelService.add(adChannel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return adChannelService.update(adChannel);
    }
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Long id){
        return adChannelService.delete(id);
    }

}
